/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.router.core.repository.mapper;

import info.peigen.hotpot.business.router.core.repository.entity.RouterTransLogEntity;
import info.peigen.hotpot.business.router.facade.enums.RouterAction;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

import java.util.List;

/**
 * <b>(RouterTransLogMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
public interface RouterTransLogMapper extends AbstractBeetlSqlMapper<RouterTransLogEntity> {
    @Sql("select * from router_trans_log where trans_log_id = ?")
    @Select
    RouterTransLogEntity findByTransLogId(String transLogId);

    @Sql("select * from router_trans_log where trade_id = ?")
    @Select
    RouterTransLogEntity findByTradeId(String tradeId);

    @Sql("select * from router_trans_log where trade_id = ? and action = ?")
    @Select
    RouterTransLogEntity findByTradeIdAndAction(String tradeId, RouterAction action);

    @Sql("select * from router_trans_log where channel_uni_id = ?")
    @Select
    RouterTransLogEntity findByChannelUniId(String channelUniId);

    @Sql("select * from router_trans_log where gateway_uni_id = ?")
    @Select
    RouterTransLogEntity findByGatewayUniId(String gatewayUniId);

    @Sql("select * from router_trans_log where action = ?")
    @Select
    List<RouterTransLogEntity> listByAction(RouterAction action);

    @Sql("delete from router_trans_log where trans_log_id = ?")
    @Update
    void deleteByTransLogId(String transLogId);

    @Sql("delete from router_trans_log where trade_id = ?")
    @Update
    void deleteByTradeId(String tradeId);

    @Sql("delete from router_trans_log where action = ? and code = ?")
    @Update
    void deleteByActionAndCode(RouterAction action, String code);
}